var t = require("../../../@babel/runtime/helpers/defineProperty"), e = getApp();

Page({
    data: {
        tabsIndex: 0,
        circleId: 0,
        circleInfo: {},
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1
    },
    onLoad: function(t) {
        this.data.circleId = t.circleId, this.getDetails(), this.getListData();
    },
    onReady: function() {},
    setTabsIndex: function(t) {
        var e = t.currentTarget.dataset.index;
        this.setData({
            tabsIndex: e
        });
    },
    getDetails: function() {
        var t = this, a = e.getNetAddresss("plugin.circle.frontend.circle.get-circle");
        e._postNetWork({
            url: a,
            data: {
                circle_id: this.data.circleId
            },
            success: function(a) {
                var i = a.data;
                if (1 != i.result) return e.tips(i.msg);
                t.setData({
                    circleInfo: i.data
                }), console.log(i);
            }
        });
    },
    getListData: function() {
        var t = this, a = e.getNetAddresss("plugin.circle.frontend.circle-member.get-circle-memberList"), i = {
            circle_id: this.data.circleId,
            is_review: 1
        };
        e._postNetWork({
            url: a,
            data: i,
            success: function(a) {
                var i = a.data;
                if (1 != i.result) return e.tips(i.msg);
                t.data.total_page = i.data.last_page, t.data.total_page || (t.data.total_page = 0), 
                t.setData({
                    listData: i.data.data,
                    networkLoading: !0
                });
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var a = e.getNetAddresss("plugin.circle.frontend.circle-member.get-circle-memberList"), i = {
                circle_id: this.data.circleId,
                is_review: 1,
                page: this.data.page
            };
            e._postNetWork({
                url: a,
                data: i,
                success: function(e) {
                    var a = e.data;
                    if (t.data.isLoadMore = !0, 1 === a.result) {
                        var i = t.data.listData.concat(a.data.data);
                        t.setData({
                            listData: i
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    outCircle: function() {
        var t = this;
        wx.showModal({
            title: "是否确认退出该圈子",
            content: "注：付费圈子退出后再次去圈子需交费",
            success: function(e) {
                console.log(e), e.confirm ? (console.log("点击确定"), t.pushOutCircle()) : e.cancel && console.log("用户点击取消");
            }
        });
    },
    pushOutCircle: function() {
        var t = e.getNetAddresss("plugin.circle.frontend.circle.quit-circle");
        e._postNetWork({
            url: t,
            data: {
                circle_id: this.data.circleId
            },
            success: function(t) {
                var a = t.data;
                if (1 != a.result) return e.tips(a.msg);
                try {
                    var i = getCurrentPages();
                    i[i.length - 2].updateView();
                } catch (t) {
                    console.log(t);
                }
                wx.navigateBack();
            }
        });
    },
    followMember: function(a) {
        var i, r, s = this, n = a.currentTarget.dataset.index, c = a.currentTarget.dataset.id, o = this.data.listData[n].is_attention, d = {
            attention_member_id: c
        };
        0 == o ? (i = 1, r = e.getNetAddresss("plugin.circle.frontend.circle-member.attention-member")) : 1 == o && (i = 0, 
        r = e.getNetAddresss("plugin.circle.frontend.circle-member.cancel-attention")), 
        e._getNetWork({
            url: r,
            data: d,
            success: function(a) {
                var r = a.data;
                if (e.tips(r.msg), 1 == r.result) {
                    var c = "listData[" + n + "].is_attention";
                    s.setData(t({}, c, i));
                }
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareTimeline: function() {},
    onShareAppMessage: function() {}
});